﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using XRM.Security.DataAccess.Enums;

namespace XRM.Security.DataAccess.Models
{
    [Table("RequestWorkKindParam")]
    public class RequestWorkKindParam
    {
        public RequestWorkKindParam()
        {
            RequestWorkKindParamSpecs = new List<RequestWorkKindParamSpec>();   
        }

        [Key]
        [DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
        public int RequestWorkKindParamId { get; set; }

        [Required]
        public int RequestWorkKindId { get; set; }
        [Required]
        public int WorkKindParamId { get; set; }

        public string ParamValue { get; set; }
        public string ParamValue1 { get; set; }

        public int? SkziKindId { get; set; }
        public int? PCId { get; set; }
        public int? InfoSystemId { get; set; }
        public int? DepartmentId { get; set; }
        public int? DepartmentAddressId { get; set; }
        public int? RequestCertId { get; set; }
        
        /*
        #region Cert fields
        [MaxLength(255)]
        public string FileName { get; set; }
        public byte[] FileData { get; set; }
        public int? IdentityCenterId { get; set; }
        
        public DateTime? UploadDate { get; set; }
        public DateTime? FromDate { get; set; }
        public DateTime? ToDate { get; set; }
        [NotMapped]
        public CertStatus Status
        {
            get
            {
                DateTime dateNow = DateTime.Today.Date;
                if (dateNow > ToDate)
                    return CertStatus.NotValid;
                else if (dateNow.AddDays(29) > ToDate)
                    return CertStatus.ExpireSoon;
                else
                    return CertStatus.Valid;
            }
        }
        [MaxLength(50)]
        public string SerialNumber { get; set; }
        [MaxLength(50)]
        public string SerialNumberEtoken { get; set; }
        [MaxLength(50)]
        public string Thumbprint { get; set; }
          
        [ForeignKey("IdentityCenterId")]
        public virtual IdentityCenter IdentityCenter { get; set; }
        #endregion
        */

        [ForeignKey("SkziKindId")]
        public virtual SkziKind SkziKind { get; set; }

        [ForeignKey("InfoSystemId")]
        public virtual InfoSystem InfoSystem { get; set; }

        [ForeignKey("PCId")]
        public virtual PC PC { get; set; }
        [ForeignKey("DepartmentId")]
        public virtual Department Department { get; set; }
        [ForeignKey("DepartmentAddressId")]
        public virtual DepartmentAddress DepartmentAddress { get; set; }
        [ForeignKey("RequestCertId")]
        public virtual RequestCert RequestCert { get; set; }

        [ForeignKey("RequestWorkKindId")]
        public virtual RequestWorkKind RequestWorkKind { get; set; }
        [ForeignKey("WorkKindParamId")]
        public virtual WorkKindParam WorkKindParam { get; set; }

        public virtual ICollection<RequestWorkKindParamSpec> RequestWorkKindParamSpecs { get; set; }
    } 
}
